package com.jziver.library.service.impl;

import com.jziver.library.entiry.BookInfo;
import com.jziver.library.repository.BookInfoRepository;
import com.jziver.library.service.BookInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by csxhu on 2016/7/5.
 */
@Service
public class BookInfoServiceImpl implements BookInfoService {

    private BookInfoRepository bookInfoRepository;

    @Autowired
    public BookInfoServiceImpl(BookInfoRepository bookInfoRepository) {
        this.bookInfoRepository = bookInfoRepository;
    }

    @Override
    public BookInfo findOne(Integer id) {
        return bookInfoRepository.findOne(id);
    }

    @Override
    public List<BookInfo> findAll() {
        return bookInfoRepository.findAll();
    }

    @Override
    public void saveOrUpdate(BookInfo bookInfo) {
        bookInfoRepository.saveAndFlush(bookInfo);
    }

    @Override
    public void delete(Integer id) {
        bookInfoRepository.delete(id);
    }
}
